package homeword;
import java.util.Scanner;
public class objectArrayMain2 {
    public static void main(String[] args) {
     objectArray2 []arr=new objectArray2[3];
     String brand;
     double price;
     String color;
     Scanner scanner=new Scanner(System.in);
        for (int i = 0; i < arr.length; i++) {
            objectArray2 r=new objectArray2();
            System.out.println("请输入品牌:");
            brand=scanner.next();
            r.setBrand(brand);
            System.out.println("请输入颜色:");
            color=scanner.next();
            r.setColor(color);
            System.out.println("请输入价格:");
            price=scanner.nextDouble();
            r.setPrice(price);
            arr[i]=r;

        }
        //使用next来存储字符串
        for (int i = 0; i < arr.length; i++) {
            objectArray2 car = arr[i];//
            System.out.println("品牌："+car.getBrand());
            System.out.println("价格："+car.getPrice());
            System.out.println("颜色："+car.getColor());
            System.out.println();
        }

    }
}
